package model

import "fmt"

type account struct {
	accountNo string
	balance   float64
	pwd       string
}

func NewAccount(accountNo string, balance float64, pwd string) *account {
	accountNoLen := len(accountNo)
	if accountNoLen > 10 || accountNoLen < 6 {
		fmt.Println("账号长度请在6-10位之间!")
		return nil
	}
	if balance <= 20 {
		fmt.Println("余额必须大于20!")
		return nil
	}
	if len(pwd) != 6 {
		fmt.Println("密码长度必须为6位!")
		return nil
	}
	return &account{
		accountNo: accountNo,
		balance:   balance,
		pwd:       pwd,
	}
}

func (account *account) SetAccountNo(accountNo string) {
	// len := len(accountNo)
	// if len > 10 && len < 6 {
	// 	fmt.Println("账号长度请在6-10位之间!")
	// 	return
	// }
	account.accountNo = accountNo
}
func (account *account) GetAccountNo() string {
	return account.accountNo
}

func (account *account) SetBalance(balance float64) {
	// if balance <= 20 {
	// 	fmt.Println("余额必须大于20!")
	// 	return
	// }
	account.balance = balance
}
func (account *account) GetBalance() float64 {
	return account.balance
}

func (account *account) SetPwd(pwd string) {
	// if len(pwd) != 6 {
	// 	fmt.Println("密码长度必须为6位!")
	// 	return
	// }
	account.pwd = pwd
}
func (account *account) GetPwd() string {
	return account.pwd
}
